<?php

namespace App\Modules\LuckDraw\LuckDraw;

use App\Modules\LuckDraw\Models\UserPropLogModel;
use Illuminate\Support\Facades\Redis;

class WorldCupLuckDraw extends LuckDrawBase implements LuckDrawInterface{
    private $_luckDrawUserRedisKey = 'LUCKDRAW:WORLDCUP:DRAW:%s:POOL:%s:USERS';
    //如果需要重写部分方法可以在这里重新
    public function run(int $num = 0): ?array
    {
        $luckId = $this->getLuckId();
        list($strategyData, $pool) = $this->userTagInstance->getStrategyPool();
        $key = sprintf($this->_luckDrawUserRedisKey, $luckId,$pool);
        Redis::SADD($key, $this->luckUserInstance->userId());
        return parent::run($num); // TODO: Change the autogenerated stub
    }

    //购买道具
    public function exchange(?int $num): array {
        list($code, $data) =  parent::exchange($num); // TODO: Change the autogenerated stub
        $price = $this->getPrice();
        $data['price'] = $price;
        return [$code, $data];
    }

    //赠送道具
    public function present(int $num) {
        $this->setPresentType(UserPropLogModel::USER_PROP_TYPE_ACT_WORLDCUP);
        return parent::present($num); // TODO: Change the autogenerated stub
    }
}